import { Controller, Get, UseGuards, Param, Post, Body, Query } from "@nestjs/common";
import { VideoService } from "./video.service";
import { JwtAuthGuard } from "../auth/jwt-auth.guard";
import { VideoEntity } from "@/db/entitys/video.entity";
import { IWonewSer } from "@/typing";
import { VideoCutTemplateService } from "./video-cut-template.service";

@Controller("video")
export class VideoController {
  constructor(
    private readonly videoService: VideoService,
    private readonly videoCutTemplateService: VideoCutTemplateService,
  ) {}

  @Get("/list")
  @UseGuards(JwtAuthGuard)
  getList(@Query() params?: IWonewSer.QueryFilterParams) {
    return this.videoService.getList(params)
  }
  @Post("/:id/update")
  @UseGuards(JwtAuthGuard)
  update(@Param("id") id: number, @Body() body: Partial<VideoEntity>) {
    return this.videoService.createOrUpdate(id, body)
  }
  @Post("/create")
  @UseGuards(JwtAuthGuard)
  create(@Body() body: Partial<VideoEntity>) {
    return this.videoService.createOrUpdate(0, body)
  }

  @Post("/:id/delete")
  @UseGuards(JwtAuthGuard)
  delete(@Param("id") id: number) {
    return this.videoService.delete(id)
  }

  @Get("/:id/info")
  @UseGuards(JwtAuthGuard)
  info(@Param("id") id: number) {
    return this.videoService.info(id)
  }

  @Post("/:id/fire")
  @UseGuards(JwtAuthGuard)
  fire(@Param("id") id: number, @Body() body: any) {
    return this.videoService.fire(id, body)
  }

  @Get("/cut-template/list")
  @UseGuards(JwtAuthGuard)
  getCutTemplateList(@Query() params?: IWonewSer.QueryFilterParams) {
    return this.videoCutTemplateService.getList(params)
  }
  @Post("/cut-template/:id/update")
  @UseGuards(JwtAuthGuard)
  updateCutTemplate(@Param("id") id: number, @Body() body: Partial<VideoEntity>) {
    return this.videoCutTemplateService.createOrUpdate(id, body)
  }
  @Post("/cut-template/create")
  @UseGuards(JwtAuthGuard)
  createCutTemplate(@Body() body: Partial<VideoEntity>) {
    return this.videoCutTemplateService.createOrUpdate(0, body)
  }

  @Post("/cut-template/:id/delete")
  @UseGuards(JwtAuthGuard)
  deleteCutTemplate(@Param("id") id: number) {
    return this.videoCutTemplateService.delete(id)
  }

  @Get("/suffix/list")
  getVideoSuffixList() {
    return this.videoService.getVideoSuffixList()
  }
}